package cn.com.template.controller.system.admin;


import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.dal.dataobject.sys.MenuDO;
import cn.com.support.context.MenuContext;

@Controller
@RequestMapping("/system/admin/menu")
public class MenuController {

	@RequestMapping("/children.json")
	@ResponseBody
	public Object childrenMenu(HttpServletRequest request) {
		int id=request.getParameter("id")==null ? 0:Integer.parseInt(request.getParameter("id"));
		if (id == 0) {
			return MenuContext.getInstance().getRoot();
		} else {
			MenuDO menu=MenuContext.getInstance().getMenuById(id);
			if(menu!=null){
				return	 menu.getChildren();
			}else{
				return null;
			}
		}
	}
}
